<template>
  <el-row class="min-h-screen bg-[#1b254c]">
    <el-col :lg="16" :md="12" class="left-box">
      <div>
        <div class="text-left font-bold text-5xl text-lime-50 leading-loose">积云教育学生管理</div>
      </div>
    </el-col>
    <el-col :lg="8" :md="12" class="right-box left-box">
      <h1 class="font-bold text-4xl text-gray-800">欢迎登录</h1>
      <div class="flex justify-center items-center my-5 text-gray-300 space-x-2">
        <span class="h-[1px] w-16 bg-gray-300"></span>
        <span>账号密码登录</span>
        <span class="h-[1px] w-16 bg-gray-300"></span>
      </div>
      <el-form ref="ruleFormRef" :model="ruleForm" status-icon class="w-[300px]">
        <el-form-item prop="name">
          <el-input :prefix-icon="User" v-model="ruleForm.username" placeholder="请输入用户名" clearable />
        </el-form-item>
        <el-form-item prop="name">
          <el-input :prefix-icon="Lock" v-model="ruleForm.password" placeholder="请输入密码" show-password clearable />
        </el-form-item>
        <el-form-item class="btn pl-16">
          <el-button color="#fff" round @click="submitForm">登录</el-button>
          <el-button color="#fff" round>重置</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script setup >
import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { User, Lock } from '@element-plus/icons-vue'
import { login } from '../utils/API'
const router = useRouter()
const ruleFormRef = ref()
const ruleForm = reactive({
  username: 'admin',
  password: '123456'
})

const submitForm = async () => {
  try {
    const res = await login(ruleForm)
    console.log(res);
    localStorage.setItem('token', res.data.token)
    router.push('/index')
  } catch (error) {
    console.log(error);
  }
}


</script>
<style scoped >
.left-box {
  @apply flex flex-col justify-center items-center
}

.right-box {
  @apply bg-[#626aef]
}

:deep(.el-input) {
  height: 45px;
}

:deep(.el-button) {
  height: 35px;
}
</style>